package util;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReadConfig {
    public static Map<String,String> read() throws Exception{
        Map<String,String> map=new HashMap<String,String>();
        SAXBuilder s=new SAXBuilder();
        String path=ReadConfig.class.getResource("/").getPath()+"config.xml";
        //System.out.print(path);
        Document dom=s.build(path);
        Element e=dom.getRootElement();
        List<Element> list=e.getChildren();
        for(int i=0;i<list.size();i++){
            //System.out.println(list.get(i).getName());
           // System.out.println(list.get(i).getText());
            map.put(list.get(i).getName(),list.get(i).getText());
        }

        return map;
    }
    public static void main(String[] args){
        ReadConfig c=new ReadConfig();
        try {
            c.read();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
